//
//  TJVisitorTableViewController.swift
//  WeiBo
//
//  Created by TanJian on 15/12/5.
//  Copyright © 2015年 Joshpell. All rights reserved.
//

import UIKit

class TJVisitorTableViewController: UITableViewController {

    
    var userLogon = TJUserAcountViewModel.shareViewModel.accessToken != nil
    
    

    var visitorVC : TJVisitorView?
    
    
    
    
    override func loadView() {

        userLogon ? super.loadView() : setupVisitorUI()
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }


    
    
    //访客模式下的界面
    private func setupVisitorUI() {
        
        visitorVC = TJVisitorView()
        
        visitorVC?.registerButton.addTarget(self , action:"login" , forControlEvents: .TouchUpInside)
        visitorVC?.loginButton.addTarget(self , action:"login" , forControlEvents: .TouchUpInside)
        view = visitorVC
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册" , target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", target: self, action: "login")
        
    }
    
    
    @objc private func login(){
        
        let loginVC = TJOAuthViewController()
        presentViewController(TJNavigationViewController(rootViewController:loginVC), animated: true, completion: nil)
        
    }

    
    
    // MARK: - Table view data source

//    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
//        // #warning Incomplete implementation, return the number of sections
//        return 0
//    }
//
//    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//        // #warning Incomplete implementation, return the number of rows
//        return 0
//    }



}
